﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace DumpMe.ViewModels
{

    public class ExceptionHandlersViewModel : INotifyPropertyChanged
    {
        public ExceptionHandlersViewModel()
        {
            Handlers = new ObservableCollection<string>();
        }

        public event PropertyChangedEventHandler PropertyChanged;

        // This method is called by the Set accessor of each property. 
        // The CallerMemberName attribute that is applied to the optional propertyName 
        // parameter causes the property name of the caller to be substituted as an argument. 
        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }



        public int Add(string exceptionHandler)
        {
            Handlers.Add(exceptionHandler);

            return Handlers.Count;
        }

        public ObservableCollection<string> Handlers { get; set; }




        /*

        private int LastOrder = 1;


        private int ad_cd_fce_o = 0;
        public int AppDomain_CurrentDomain_FirstChanceException_Order
        {
            get
            {
                return this.ad_cd_fce_o;
            }

            set
            {
                this.ad_cd_fce_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool ad_cd_fce = false;
        public bool AppDomain_CurrentDomain_FirstChanceException
        {
            get
            {
                return this.ad_cd_fce;
            }

            set
            {
                this.ad_cd_fce = value;
                NotifyPropertyChanged();

                AppDomain_CurrentDomain_FirstChanceException_Order = LastOrder;
                LastOrder += 1;
            }
        }

        private int ad_cd_fce2_o = 0;
        public int AppDomain_CurrentDomain_FirstChanceException2_Order
        {
            get
            {
                return this.ad_cd_fce2_o;
            }

            set
            {
                this.ad_cd_fce2_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool ad_cd_fce2 = false;
        public bool AppDomain_CurrentDomain_FirstChanceException2
        {
            get
            {
                return this.ad_cd_fce2;
            }

            set
            {
                this.ad_cd_fce2 = value;
                NotifyPropertyChanged();

                AppDomain_CurrentDomain_FirstChanceException2_Order = LastOrder;
                LastOrder += 1;
            }
        }

        private int ad_cd_ue_o = 0;
        public int AppDomain_CurrentDomain_UnhandledException_Order
        {
            get
            {
                return this.ad_cd_ue_o;
            }

            set
            {
                this.ad_cd_ue_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool ad_cd_ue = false;
        public bool AppDomain_CurrentDomain_UnhandledException
        {
            get
            {
                return this.ad_cd_ue;
            }

            set
            {
                this.ad_cd_ue = value;
                NotifyPropertyChanged();

                AppDomain_CurrentDomain_UnhandledException_Order = LastOrder;
                LastOrder += 1;
            }
        }

        private int a_c_d_uef_o = 0;
        public int Application_Current_Dispatcher_UnhandledExceptionFilter_Order
        {
            get
            {
                return this.a_c_d_uef_o;
            }

            set
            {
                this.a_c_d_uef_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool a_c_d_uef = false;
        public bool Application_Current_Dispatcher_UnhandledExceptionFilter
        {
            get
            {
                return this.a_c_d_uef;
            }

            set
            {
                this.a_c_d_uef = value;
                NotifyPropertyChanged();

                Application_Current_Dispatcher_UnhandledExceptionFilter_Order = LastOrder;
                LastOrder += 1;
            }
        }

        private int a_c_d_ue_o = 0;
        public int Application_Current_Dispatcher_UnhandledException_Order
        {
            get
            {
                return this.a_c_d_ue_o;
            }

            set
            {
                this.a_c_d_ue_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool a_c_d_ue = false;
        public bool Application_Current_Dispatcher_UnhandledException
        {
            get
            {
                return this.a_c_d_ue;
            }

            set
            {
                this.a_c_d_ue = value;
                NotifyPropertyChanged();

                Application_Current_Dispatcher_UnhandledException_Order = LastOrder;
                LastOrder += 1;
            }
        }

        private int a_c_due_o = 0;
        public int Application_Current_DispatcherUnhandledException_Order
        {
            get
            {
                return this.a_c_due_o;
            }

            set
            {
                this.a_c_due_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool a_c_due = false;
        public bool Application_Current_DispatcherUnhandledException
        {
            get
            {
                return this.a_c_due;
            }

            set
            {
                this.a_c_due = value;
                NotifyPropertyChanged();

                Application_Current_DispatcherUnhandledException_Order = LastOrder;
                LastOrder += 1;
            }
        }

        private int _finally_o = 0;
        public int Finally_Order
        {
            get
            {
                return this._finally_o;
            }

            set
            {
                this._finally_o = value;
                NotifyPropertyChanged();
            }
        }

        private bool _finally = false;
        public bool Finally
        {
            get
            {
                return this._finally;
            }

            set
            {
                this._finally = value;
                NotifyPropertyChanged();

                Finally_Order = LastOrder;
                LastOrder += 1;
            }
        }
        */

        internal void Reset()
        {
            //AppDomain_CurrentDomain_FirstChanceException = false;
            //AppDomain_CurrentDomain_FirstChanceException2 = false;
            //AppDomain_CurrentDomain_UnhandledException = false;
            //Application_Current_Dispatcher_UnhandledExceptionFilter = false;
            //Application_Current_Dispatcher_UnhandledException = false;
            //Application_Current_DispatcherUnhandledException = false;
            //Finally = false;

            //AppDomain_CurrentDomain_FirstChanceException_Order = 0;
            //AppDomain_CurrentDomain_FirstChanceException2_Order = 0;
            //AppDomain_CurrentDomain_UnhandledException_Order = 0;
            //Application_Current_Dispatcher_UnhandledExceptionFilter_Order = 0;
            //Application_Current_Dispatcher_UnhandledException_Order = 0;
            //Application_Current_DispatcherUnhandledException_Order = 0;
            //Finally_Order = 0;

            //LastOrder = 1;

            Handlers.Clear();

        }
    }
}
